﻿using Digitalmes.Domain.Entities.Mes.Masters;

namespace Digitalmes.Application.Mes.Masters.Workshops.Commands;

/// <summary>
/// 删除车间信息命令。
/// </summary>
/// <param name="WorkshopId"></param>
public record DeleteWorkshopCommand(long WorkshopId) : IRequest<IResult<bool>>;

internal sealed class DeleteWorkshopCommandHandler(IRepository<MdWorkshop> repo) : IRequestHandler<DeleteWorkshopCommand, IResult<bool>>
{
    public async Task<IResult<bool>> Handle(DeleteWorkshopCommand request, CancellationToken cancellationToken)
    {
        var ok = await repo.DeleteByIdAsync(request.WorkshopId, cancellationToken);
        return Result.From(ok);
    }
}
